package com.shaozi.nc.manage.observer;

import java.util.Observable;
import java.util.Observer;

import com.shaozi.data.mq.business.base.SourceTypeConsts.OA.Crm_Custom;
import com.shaozi.data.mq.business.base.SourceTypeConsts.OA.Task;
import com.shaozi.data.mq.business.observer.MqTargetObserverBean;
import com.shaozi.nc.manage.observer.base.BaseSecretaryObserver;

/**
 * crm客服观察者 https://shimo.im/doc/BESz6u08M9Ap3Ju7
 * 
 * @author lyx
 *
 */
public class CrmCustomerObserver extends BaseSecretaryObserver implements Observer {

	// 查看任务 :9525,9526,9528,9522,9523,9527,9529
	private static final Integer[] Rule_Look_Report_sourceType = { Crm_Custom.Created, Crm_Custom.Status, Crm_Custom.Actor,
			Crm_Custom.AddComment, Crm_Custom.ReplyComment, Crm_Custom.Principal, Crm_Custom.Alarm };
	// 评论/回复评论 7015,7017
	private static final Integer[] Reply_or_Comment_sourceType = { Crm_Custom.AddComment, Crm_Custom.ReplyComment };

	@Override
	public void update(Observable o, Object arg) {
		if (arg != null) {
			if (arg instanceof MqTargetObserverBean) {
				MqTargetObserverBean mqBean = (MqTargetObserverBean) arg;
				int sourceType = mqBean.getSourceType();
				switch (sourceType) {
				case Crm_Custom.Rule_Look_Report:// 查看任务
					updateUserRead(sourceType, mqBean, Rule_Look_Report_sourceType);
					break;
				case Crm_Custom.AddComment:
				case Crm_Custom.ReplyComment:// 评论/回复评论
					updateUserRead(sourceType, mqBean, Reply_or_Comment_sourceType);
					break;
				default:
					break;
				}
			}
		}
	}

}
